<template>
  <!--视图-->
  <div>
    <button @click="show">获取奇数行</button><br>

   <span v-for="u in users" :class="myClass">
     {{u.date}}-{{u.name}}-{{u.age}}-{{u.city}}<br>
   </span>
  </div>
</template>

<script>
export default {
  name: "ListView",
  data() {//属性
    return {
      myClass:'myClass',
      users:[{id:100,date:'2016-5-2',name:'zhangsan',age:20,city:'天津'},
        {id:200,date:'2016-6-2',name:'zhangsan2',age:20,city:'天津2'},{id:300,date:'2016-5-2',name:'zhangsan3',age:20,city:'天津3'}]

    }
  }, methods: {//自定义方法
    show(){
      this.users.forEach((u,index)=>{
        if(index %2==0){
          alert(u.id)
        }

      })
    }
  }, created() { //钩子函数

  }
}
</script>

<style scoped>
.myClass:hover{
  background-color: green;
}
</style>